package tests.flexunit.utils
{
	import flexunit.framework.AssertionFailedError;
	import flexunit.framework.TestCase;
	
	import funit.resources.AssertResources;
	
	import mx.core.Application;
	import mx.core.LayoutContainer;
	
	import sv.utils.ClassUtil;
	
	public class GetBaseClassTests extends TestCase
	{
		
		
		public function GetBaseClassTests( methodName:String = null )
		{
			super(methodName);
		}
		
		
//------------------------------------------------------------------------------
		
		public function testGetClassByInstance() : void
		{
			assertStrictlyEquals( LayoutContainer, ClassUtil.getBaseClass(new Application()) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetClassByClass() : void
		{
			assertStrictlyEquals( LayoutContainer, ClassUtil.getBaseClass(Application) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetClassByBaseInstance() : void
		{
			assertNull( ClassUtil.getBaseClass(new Object()) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetClassByBaseClass() : void
		{
			assertNull( ClassUtil.getBaseClass(Object) );
		}
		
//------------------------------------------------------------------------------		
		
		public function testGetClassByPrimitiveInstance() : void
		{
			assertStrictlyEquals( Object, ClassUtil.getBaseClass(true) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetClassByPrimitiveClass() : void
		{
			assertStrictlyEquals( Object, ClassUtil.getBaseClass(Boolean) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetClassFailureOnNull() : void
		{
			try
			{
				ClassUtil.getBaseClass(null);
			}
			catch ( e:ArgumentError )
			{
				return;
			}
			catch ( e:Error )
			{
				throw	new AssertionFailedError(
							AssertResources.getString("Errors.AssertFailedError.UnexpectedErrorType", ClassUtil.getQualifiedClassName(e))
						);
			}
			
			throw	new AssertionFailedError(
							AssertResources.getString("Errors.AssertFailedError.ErrorTypeExpected", ClassUtil.getQualifiedClassName(ArgumentError))
						);
		}
		
//------------------------------------------------------------------------------
	
	}
	
}
